#include "Triangle.h"

Triangle::Triangle(const Vector3D& vector1, const Vector3D& vector2, const Vector3D& vector3)
:	vector1(vector1), vector2(vector2), vector3(vector3) {
}

// WARNUNG: derzeit wird die methode nicht benutzt
Vector3D Triangle::calculateSurfaceNormal() {
	Vector3D ns;
	// see http://www.opengl.org/wiki/Calculating_a_Surface_Normal
	ns.x = (vector2.y - vector1.y) * (vector3.z - vector1.z) - (vector2.z - vector1.z) * (vector3.y - vector1.y);
	ns.y = (vector2.z - vector1.z) * (vector3.x - vector1.x) - (vector2.x - vector1.x) * (vector3.z - vector1.z);
	ns.z = (vector2.x - vector1.x) * (vector3.y - vector1.y) - (vector2.y - vector1.y) * (vector3.x - vector1.x);
	ns.normalize();
	return ns;
}